//
//  ZWBaseTableViewController.swift
//  张伟的微博
//
//  Created by 伟 on 16/2/27.
//  Copyright © 2016年 伟. All rights reserved.
//

import UIKit

class ZWBaseTableViewController: UITableViewController {

    var userLodin = ZWUserAccountViewModel.sharedInstance.userLodin
    override func loadView() {
        
        userLodin ? super.loadView() : setupVistorView()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
    }
    
    func setupVistorView() {
       self.view = vistorView
        //4 设置代理
        vistorView.vistorViewDelegate = self
       
        if self is ZWHomeTableViewController {
            //让他旋转
            vistorView.iconViewRevolve()
        
        } else if (self is ZWMessageTableViewController) {
            vistorView.setVistorView("visitordiscover_image_message", msgLabel: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
            print("ZWMessageTableViewController")
    
        } else if (self is ZWProfileTableViewController) {
            vistorView.setVistorView("visitordiscover_image_profile", msgLabel: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            print("2")
        
        } else if (self is ZWDiscoberTableViewController) {
            vistorView.setVistorView("visitordiscover_image_message", msgLabel: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        
        }
        //设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "vistorViewRegisterButtonClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "vistorViewLoadButtonClick")
    
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    //MARK: - 懒加载
    lazy var vistorView:ZWVistorView = ZWVistorView()
    
    
   
}
    //MARK: - 实现ZWVistorDelegate
extension ZWBaseTableViewController: ZWVistorDelegate {
    func vistorViewRegisterButtonClick () {
        let netWork = ZWNetWorwTool.sharedInstance
        print("\(netWork)")
      
    }
    
    func vistorViewLoadButtonClick () {
        let webView = ZWOauthViewController()
        presentViewController(UINavigationController(rootViewController: webView), animated: true, completion:nil)
        
    
    
   }
    
}

